Skip to content

feat(cli): add --region to project create and fix default region on new app deploys#120

Merged
kristof-siket merged 3 commits into
mainfrom
prs-195-cli-project-region-behavior
Jul 14, 2026
Merged

feat(cli): add --region to project create and fix default region on new app deploys#120
kristof-siket merged 3 commits into
mainfrom
prs-195-cli-project-region-behavior

Conversation

@kristof-siket

@kristof-siket kristof-siket commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • project create --region <region>: new flag threads through runProjectCreateAppProvider.createProject → SDK createProject({ region }). The platform assigns its default when omitted.
  • Fix default region bug: deployNewAppRegion was returning DEFAULT_REGION = "eu-central-1" when no --region is passed. It now returns undefined, so new apps created without --region land in the project's server-assigned region instead of always Frankfurt.
  • app deploy --create-project <name> --region <region>: createProjectRegion is now threaded through the deploy project context so the implicit project creation picks up the CLI flag.
  • Display: defaultRegion flows through all three toProjectSummary copies (setup.ts, resolution.ts, use-cases/project.ts) into ProjectSummary. project show renders a region row. project list adds a region column (absent value: dimmed "none"). On deploy without --region, the main output prints the server-resolved region with provenance: "project default" when the project carries a defaultRegion, otherwise "platform default — pass --region to choose". Explicit --region suppresses the provenance suffix.
  • Dead code removal: selectRegion stub on DeployInteraction is deleted — interaction: undefined is always passed to sdk.deploy; createBranchApp creates the app first so sdk.deploy always receives a concrete appId and never reaches the #resolveDeployTarget region shortcut.

SDK dependency

The companion SDK PR is prisma/project-compute#108 (makes region?: string genuinely optional in app-creation: regionId spread only when present, selectRegion hook becomes optional returning string | undefined, missing-argument region branch removed). The stub removal and createBranchApp optionality already work against the current SDK (v0.34.0) because:

  • createBranchApp always called before sdk.deploy for new apps → sdk.deploy gets a concrete appId (fast path)
  • CreateProjectOptions.region?: string already exists in v0.34.0

Breaking behavior change

Previous behavior: app deploy without --region always created new apps in eu-central-1 (the hardcoded DEFAULT_REGION). New behavior: omitting --region lets the server assign the region from the project default. Users who relied on implicit Frankfurt placement will now see the project's default region applied. The deploy output now makes the server-resolved region visible with provenance so the behavior change is informed rather than silent.

Test plan

  • project create --region us-east-1createProject called with { name, region: "us-east-1", signal } (new test in project-controller.test.ts)
  • app deploy --create-project my-proj --region us-east-1createProject called with { name, region: "us-east-1", signal } (new test in app-controller.test.ts)
  • deployApp without --region → POST /v1/apps body omits regionId (existing test, now verifying the bug fix: the old test was named "default Frankfurt region" and asserted region: "eu-central-1"; updated to region: undefined)
  • deployApp with region: "us-east-1" → POST /v1/apps body includes regionId: "us-east-1" (new test in app-provider.test.ts)
  • Deploy without --region + no project defaultRegion → output contains region value and "platform default — pass --region to choose" (new test in app-presenter.test.ts)
  • Deploy without --region + project defaultRegion set → output contains region value and "project default" (new test in app-presenter.test.ts)
  • Deploy with explicit --region (regionSource non-null) → output contains no provenance suffix (new test in app-presenter.test.ts)
  • All 636 tests pass (pnpm --filter @prisma/cli test)
  • TypeScript clean (tsc --noEmit)
  • Biome format applied, no errors

🤖 Generated with Claude Code

…ew app deploys

Add --region <region> flag to `project create`, thread it through implicit
project creation in `app deploy --create-project`, and remove the hardcoded
DEFAULT_REGION ("eu-central-1") fallback so apps created without --region
inherit the project's server-assigned default rather than always landing in
Frankfurt. Also surface `defaultRegion` from the project API in `project show`
output and add `defaultRegion` to ProjectRecord and ProjectSummary types.

The selectRegion stub on DeployInteraction is removed entirely — it was dead
code (interaction: undefined is always passed to sdk.deploy; the branch-app
path calls createBranchApp directly before sdk.deploy, so sdk.deploy always
receives a concrete appId and never reaches #resolveDeployTarget's region
shortcut).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 28 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 92a8a052-499d-4387-a4a2-e247a501ff6c

📥 Commits

Reviewing files that changed from the base of the PR and between e70d813 and f1a28de.

📒 Files selected for processing (11)
  • docs/product/command-spec.md
  • packages/cli/src/controllers/app.ts
  • packages/cli/src/controllers/project.ts
  • packages/cli/src/lib/project/resolution.ts
  • packages/cli/src/lib/project/setup.ts
  • packages/cli/src/presenters/app.ts
  • packages/cli/src/presenters/project.ts
  • packages/cli/src/types/app.ts
  • packages/cli/src/use-cases/project.ts
  • packages/cli/tests/app-presenter.test.ts
  • packages/cli/tests/project.test.ts

Walkthrough

The project create command now accepts an optional --region value and forwards it to project creation APIs. Project and app providers expose default regions and propagate deployment regions into app creation requests. Deployment setup no longer applies a hard-coded region when none is specified, while supporting region forwarding during project creation. Project display output, command documentation, and controller/provider tests were updated accordingly.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main CLI region changes and the new app deploy behavior.
Description check ✅ Passed The description is directly related to the region flag, deploy behavior, and related output/type updates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch prs-195-cli-project-region-behavior
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch prs-195-cli-project-region-behavior

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/cli/src/controllers/project.ts (1)

316-324: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Newly-created project's defaultRegion is discarded at both create-project call sites. provider.createProject returns defaultRegion (see app-provider.ts), but both places that consume it drop the field when building the resulting project object, so downstream consumers (e.g. project create output) never see the server-assigned region even though the type now supports it.

  • packages/cli/src/controllers/project.ts#L316-L324: include defaultRegion: created.defaultRegion in the object passed to bindProjectToDirectory.
  • packages/cli/src/controllers/app.ts#L3630-L3658: include defaultRegion: created.defaultRegion in the returned ProjectCandidate.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/controllers/project.ts` around lines 316 - 324, The newly
created project's defaultRegion is omitted at both create-project call sites. In
packages/cli/src/controllers/project.ts lines 316-324, update the object passed
to bindProjectToDirectory to include created.defaultRegion; in
packages/cli/src/controllers/app.ts lines 3630-3658, include
created.defaultRegion in the returned ProjectCandidate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/product/command-spec.md`:
- Line 706: Update the `prisma-cli project create` heading to wrap the optional
`--region <region>` argument in brackets, matching the documented optional
behavior and the formatting used by other optional arguments.

---

Outside diff comments:
In `@packages/cli/src/controllers/project.ts`:
- Around line 316-324: The newly created project's defaultRegion is omitted at
both create-project call sites. In packages/cli/src/controllers/project.ts lines
316-324, update the object passed to bindProjectToDirectory to include
created.defaultRegion; in packages/cli/src/controllers/app.ts lines 3630-3658,
include created.defaultRegion in the returned ProjectCandidate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 37460063-f415-4a76-b844-1c31fc99f9f2

📥 Commits

Reviewing files that changed from the base of the PR and between 10f6c43 and e70d813.

📒 Files selected for processing (11)
  • docs/product/command-spec.md
  • packages/cli/src/commands/project/index.ts
  • packages/cli/src/controllers/app.ts
  • packages/cli/src/controllers/project.ts
  • packages/cli/src/lib/app/app-interaction.ts
  • packages/cli/src/lib/app/app-provider.ts
  • packages/cli/src/presenters/project.ts
  • packages/cli/src/types/project.ts
  • packages/cli/tests/app-controller.test.ts
  • packages/cli/tests/app-provider.test.ts
  • packages/cli/tests/project-controller.test.ts

Comment thread docs/product/command-spec.md Outdated
kristof-siket and others added 2 commits July 14, 2026 11:43
When a deploy runs without --region, the main output now shows the
server-resolved region with provenance: "project default" when the
project has a defaultRegion, "platform default — pass --region to
choose" otherwise. Explicit --region suppresses the provenance suffix.

Also propagates defaultRegion through all three toProjectSummary copies
(setup.ts, resolution.ts, use-cases/project.ts) and adds a defaultRegion
column to `project list` output (absent value: dimmed "none").

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…tion

Both create-project call sites dropped the provider's defaultRegion, so
project create output and the deploy-setup candidate never showed the
server-assigned region. Also mark --region optional in the command-spec
heading.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@kristof-siket

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@kristof-siket kristof-siket merged commit 1cd0121 into main Jul 14, 2026
10 checks passed
@kristof-siket kristof-siket deleted the prs-195-cli-project-region-behavior branch July 14, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant